<template>
  <el-table :data="medicalTechList" ref="checkRequestTable">
    <el-table-column type="selection"/>
    <el-table-column prop="techCode" label="检查编码"/>
    <el-table-column prop="techName" label="检查名称"/>
    <el-table-column prop="techFormat" label="检查规格"/>
    <el-table-column prop="techPrice" label="单价"/>
    <el-table-column prop="priceType" label="费用分类"/>
    <el-table-column align="right">
      <template #header>
        <el-button type="success" plain @click="addMedicalTech">添加</el-button>
        <el-button type="danger" plain @click="delMedicalTech">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <MedicalTechnologySearchView :store="$store"></MedicalTechnologySearchView>
</template>

<script>
import MedicalTechnologySearchView from "@/views/MedicalTechnologySearchView";
export default {
  name: "CheckRequestTableView",
  components: {MedicalTechnologySearchView},
  data() {
    return {
      medicalTechList: []
    }
  },
  methods: {
    addMedicalTech() {
      this.$store.commit("setTechSearchVisible", true)
    },
    delMedicalTech() {
      this.medicalTechList = this.medicalTechList.filter(item => {
        for (let checkRequest of this.$refs.checkRequestTable.getSelectionRows()) {
          if (checkRequest.id == item.id) {
            return false;
          }
        }
        return true;
      })
    }
  },
  mounted() {
    this.$bus.on("sendTechList", (techList) => {
      this.medicalTechList.push(...techList)
    })
  }
}
</script>

<style scoped>

</style>